Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor apparmor utils in e2e #84439

Merged
merged 1 commit into from
Nov 14, 2019
Merged

Conversation

danielqsj
Copy link
Contributor

What type of PR is this?

/kind feature
/sig testing

What this PR does / why we need it:

test/e2e/common is a mixture of tests (test/e2e/common/downward_api.go) and utility code (test/e2e/common/events.go). It would be nice to refactor it so that the utility code can be imported without also importing the tests. Most likely a better place for the utility code is under test/e2e/framework.

Which issue(s) this PR fixes:

part of #83937

Special notes for your reviewer:

/cc @pohly

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. labels Oct 28, 2019
Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

I think this change makes a lot of sense. Would also love someone with more direct ownership of test/e2e to sign-off that framework is the proper home.

Also, would love you mind addressing the golint errors? Thank you!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 28, 2019
Copy link
Contributor

@alejandrox1 alejandrox1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for working on this @danielqsj !
Added a couple comments to guide the refactoring into the e2e test framework.
Overall, we want to include any code that may be useful for a user to test behaviour, if there is code that is specific to a test then the code should stay within the test.

A big thing is that function within an e2e test framework (test/e2e/framework/<pkg>) should not import the e2e test framework in order to avoid circular dependencies and to keep a clean interface.
A lof of the functions that are being moved over are of the form

func someMethod(f *framework.Framework) {
  ...
}

All these functions should be refactored to instead use the thing that is required from the test framework.
For example, a lof of code does something like f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(cm). This should be refactored to instead take a client interface and a namespace string as arguments to have ClientSet.CoreV1().ConfigMaps(Namespace).Create(cm) within the method.

/priority important-soon
/lgtm cancel
/milestone v1.17

test/e2e/node/apparmor.go Outdated Show resolved Hide resolved
test/e2e/auth/pod_security_policy.go Outdated Show resolved Hide resolved
test/e2e/node/apparmor.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Oct 28, 2019
@k8s-ci-robot k8s-ci-robot added this to the v1.17 milestone Oct 28, 2019
@k8s-ci-robot k8s-ci-robot removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Oct 28, 2019
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 29, 2019
@danielqsj
Copy link
Contributor Author

@alejandrox1 thanks for your review. It's a great guideline for this series of refactors.
PR updated, PTAL :)

@mattjmcnaughton
Copy link
Contributor

Thank you very much for working on this @danielqsj !
Added a couple comments to guide the refactoring into the e2e test framework.
Overall, we want to include any code that may be useful for a user to test behaviour, if there is code that is specific to a test then the code should stay within the test.

A big thing is that function within an e2e test framework (test/e2e/framework/<pkg>) should not import the e2e test framework in order to avoid circular dependencies and to keep a clean interface.
A lof of the functions that are being moved over are of the form

func someMethod(f *framework.Framework) {
  ...
}

All these functions should be refactored to instead use the thing that is required from the test framework.
For example, a lof of code does something like f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Create(cm). This should be refactored to instead take a client interface and a namespace string as arguments to have ClientSet.CoreV1().ConfigMaps(Namespace).Create(cm) within the method.

/priority important-soon
/lgtm cancel
/milestone v1.17

Thanks for your insights here @alejandrox1 !

@josiahbjorgaard
Copy link
Contributor

Hi, bug triage for v1.17 checking in to see if this PR will be merged before code freeze on Nov. 14?

@danielqsj
Copy link
Contributor Author

/cc @oomichi

@@ -23,7 +23,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/kubernetes/pkg/security/apparmor"
"k8s.io/kubernetes/test/e2e/framework"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
Copy link
Member

@oomichi oomichi Nov 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency way is not valid (e2e core framework to e2e framework subpackages(e2epod in this case).
I hesitate to merge this into the core framework at this time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't like this dependency here.
But if we looks into other files in framework, there are many place also has this dependency issue.
We need to sort out the calling relationship of each components of e2e framework.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielqsj

But if we looks into other files in framework, there are many place also has this dependency issue.

Yes, you are right.
Then we are trying to remove such invalid dependencies from the existing places.
I feel it is not necessary to add more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oomichi does one e2e framework subpackages has dependency of another e2e framework subpackage seems good ?
If it's good, I can move the apparmor.go to a dedicated subpackage like security.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this will add the dependency of the package e2e/framework directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened an issue to track this issue: #85193

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielqsj

@oomichi does one e2e framework subpackages has dependency of another e2e framework subpackage seems good ?

That is a nice point. IIUC we never discussed the dependency between subpackages.
I guess the dependency could be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. Re-implemented this change by moving it to a new subpackage.
@oomichi Please help review it ? Thanks

@josiahbjorgaard
Copy link
Contributor

@oomichi Do you think that this will be merged before v1.17 code freeze 11/14 5pm pacific time?

@oomichi
Copy link
Member

oomichi commented Nov 13, 2019

@josiahbjorgaard

Do you think that this will be merged before v1.17 code freeze 11/14 5pm pacific time?

It's up to @danielqsj if we can see a PR which has clean dependency.

@danielqsj
Copy link
Contributor Author

PR updated

@oomichi
Copy link
Member

oomichi commented Nov 14, 2019

@danielqsj Thanks for updating, much better for me.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 14, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielqsj, oomichi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 14, 2019
@k8s-ci-robot k8s-ci-robot merged commit 55cef80 into kubernetes:master Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants